home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
pdox35sc.zip
/
BOXDRAW.SC
< prev
next >
Wrap
Text File
|
1991-06-10
|
16KB
|
215 lines
; ***************************************************************************************
; DRAW A COLORED BOX AT GIVEN COORDINATES
; Copyright 1991 Virginia B. Sauer All Rights Reserved
; This program may be copied/modified without charge provided both that this
; copyright notice is included without change, and that any accompanying
; documentation includes the notice "Portions of code (c) Copyright 1991,
; Virginia B. Sauer"
; ***************************************************************************************
; Although text/endtext commands make it easy to design elaborate screens, such
; procedures can literally "eat" memory. This is particularly critical when developing
; runtime applications: having no way to determine each user's hardware and software
; constraints, it is imperative to design each system as efficiently as possible.
; The following generic utility has therefore been designed to automatically draw any
; type (double, single, or wide-lined) or color box at any given coordinate.
; Much less memory and disk space is consumed. Likewise, although slightly more
; cumbersome at first, this eliminates the necessity of constantly looking up Ascii codes
; whenever a box must be drawn (particularly in the case of wide lines, which are not
; available through standard text editors).
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ PARAMETERS PASSED TO THIS PROCEDURE ║
; ╟───────────┬──────────────────────────────────────────────────────┬───────────────────╢
; ║ ARGUMENT │ DESCRIPTION │ SAMPLE ║
; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
; ║ │ Whether the box is to be formed with single (│), │ "Double" ║
; ║ │ double (║), or wide (█) lines. │ ║
; ║ LineType │ │ (To signify a ║
; ║ │ N. B. Unless this is a variable, it must be │ box made with ║
; ║ │ enclosed in quotes. │ double lines) ║
; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
; ║ │ │ 63 ║
; ║ │ The color of the box to be drawn on-screen (based │ ║
; ║ BoxColor │ on the text attributes in the Paradox manual) │ (To signify white ║
; ║ │ │ text on a cyan ║
; ║ │ │ background) ║
; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
; ║ │ │ 03 ║
; ║ │ │ ║
; ║ StartRow │ The number of the row of the canvas on which the │ (To draw the top ║
; ║ │ top line of the box is to appear. │ line of the box ║
; ║ │ │ on the third row ║
; ║ │ │ of the canvas) ║
; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
; ║ │ │ 11 ║
; ║ │ │ ║
; ║ │ The number of the column of the canvas on which the │ (To place the ║
; ║StartColumn│ upper left-hand corner of the box is to appear. │ upper left-hand ║
; ║ │ │ corner of the box ║
; ║ │ │ on the eleventh ║
; ║ │ │ column of the ║
; ║ │ │ canvas) ║
; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
; ║ │ │ 21 ║
; ║ │ │ ║
; ║ │ │ (To draw the ║
; ║ EndRow │ The number of the row of the canvas on which the │ bottom line of ║
; ║ │ last line of the box is to appear. │ the box on the ║
; ║ │ │ twenty-first row ║
; ║ │ │ of the canvas) ║
; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
; ║ │ │ 64 ║
; ║ │ │ ║
; ║ EndColumn │ The number of the column of the canvas on which the │ (To place the ║
; ║ │ lower right-hand corner of the box is to appear. │ lower right-hand ║
; ║ │ │ corner of the box ║
; ║ │ │ on the sixty- ║
; ║ │ │ fourth column of ║
; ║ │ │ the canvas) ║
; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
; ║ │ If applicable, the first horizontal line drawn │ 19 ║
; ║ │ inside of the box to help clearly present and │ ║
; ║ │ segregate information. │ (To place a hori- ║
; ║FirstCross │ │ zontal line in- ║
; ║ │ │ side of the box ║
; ║ │ (If no horizontal lines are to appear within the │ on row 19 of the ║
; ║ │ box, enter "" for this variable) │ canvas) ║
; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
; ║ │ If applicable, the next horizontal line drawn inside │ "" ║
; ║ │ of the box to help clearly present and segregate │ ║
; ║ NextCross │ information. │ (To signify that ║
; ║ │ │ the box does not ║
; ║ │ (If the box will contain either no horizontal lines │ have a second ║
; ║ │ or only one such line, enter "" for this variable) │ second "cross- ║
; ║ │ │ line") ║
; ╚═══════════╧══════════════════════════════════════════════════════╧═══════════════════╝
Proc Draw_Box(LineType,BoxColor,StartRow,StartColumn,Endrow,EndColumn,FirstCross,NextCross)
Private FillNum, ; Number of horizontal characters to fill in
X ; A counter
; -------------------------------------------------------------------------------------
; Determine the number of horizontal characters to fill in between starting and ending
; columns
; -------------------------------------------------------------------------------------
Fillnum = (EndColumn - StartColumn -1)
; -------------------------------------------------------------------------------------
; Determine appropriate character for each part of the box (e. g., for each type of
; line (single, double, and wide), the upper lefthand corner, upper right hand corner,
; lower left hand corner, lower right hand corner, horizontal, and vertical ... As the
; wide lines distinguish betwen horizontal "top" and "bottom" characters, both
; HorizontalTop and HorizontalBottom are cited.
; -------------------------------------------------------------------------------------
Switch
Case Upper(LineType) = "SINGLE": UpperLeft = "\218" UpperRight = "\191"
LeftCross = "\195" RightCross = "\180"
LowerLeft = "\192" LowerRight = "\217"
HorizontalTop = "\196" HorizontalBottom = "\196"
Vertical = "\179"
Case Upper(LineType) = "DOUBLE": UpperLeft = "\201" UpperRight = "\187"
LeftCross = "\204" RightCross = "\185"
LowerLeft = "\200" LowerRight = "\188"
HorizontalTop = "\205" HorizontalBottom = "\205"
Vertical = "\186"
Case Upper(LineType) = "WIDE": UpperLeft = "\219" UpperRight = "\219"
LeftCross = "\219" RightCross = "\219"
LowerLeft = "\219" LowerRight = "\219"
HorizontalTop = "\223" HorizontalBottom = "\220"
Vertical = "\219"
EndSwitch
; -------------------------------------------------------------------------------------
; Specify the color in which to draw the box
; -------------------------------------------------------------------------------------
PaintCanvas Attribute BoxColor StartRow, StartColumn, EndRow, EndColumn Style Attribute BoxColor
; -------------------------------------------------------------------------------------
; At the designated coordinate, draw the top line of the box
; -------------------------------------------------------------------------------------
@ StartRow, StartColumn ?? UpperLeft, Fill(HorizontalTop,FillNum), UpperRight
; -------------------------------------------------------------------------------------
; Fill in with vertical lines extending from the starting row to the ending row
; -------------------------------------------------------------------------------------
For X From (StartRow + 1) to (EndRow - 1)
@ X,StartColumn ?? Vertical ; Vertical lines at the "starting" column
@ X,EndColumn ?? Vertical ; Vertical lines at the "ending" column
EndFor
; -------------------------------------------------------------------------------------
; If applicable, add intersecting horizontal "crosslines"
; -------------------------------------------------------------------------------------
If not isblank(FirstCross)
Then @ FirstCross, StartColumn ?? LeftCross, Fill(HorizontalTop,FillNum), RightCross
If not isblank(NextCross)
Then @ NextCross, StartColumn ?? LeftCross, Fill(HorizontalTop,FillNum), RightCross
Endif
Endif
@ EndRow, StartColumn ?? LowerLeft, Fill(HorizontalBottom,FillNum), LowerRight
Endproc
; ----------------------------------------------------------------------------------------
; If desired, an additional horizontal line may be drawn across the canvas (Since this is
; the exception rather than the rule, it is separated from the "main" box-making
; procedure to prevent wasting space with seldom- used variables)
; ----------------------------------------------------------------------------------------
Proc Cross_Line(LineType,StartRow,StartColumn,EndColumn)
Private FillNum, ; Number of characters to fill in
X, ; A counter
DOUBLESINGLE ; Single line drawn across double-lined box
; -------------------------------------------------------------------------------------
; Determine the number of horizontal characters to fill in between starting and ending
; columns
; -------------------------------------------------------------------------------------
Fillnum = (EndColumn - StartColumn -1)
; -------------------------------------------------------------------------------------
; Determine appropriate "crossline" character for each part of the box (e. g., for
; each type of line (single, double, and wide), the left-hand side character, the
; right-hand side character, and the horizontal character)
; -------------------------------------------------------------------------------------
Switch
Case Upper(LineType) = "SINGLE" : LeftCross = "\195" ; ├
HorizontalCross = "\196" ; ─
RightCross = "\180" ; ┤
Case Upper(LineType) = "DOUBLE" : LeftCross = "\204" ; ╠
HorizontalCross = "\205" ; ═
RightCross = "\185" ; ╣
Case Upper(LineType) = "WIDE" : LeftCross = "\219" ; █
HorizontalCross = "\223" ; ▀
RightCross = "\219" ; █
Case Upper(LineType) = "DOUBLESINGLE" : LeftCross = "\199" ; ╟
HorizontalCross = "\196" ; ─
RightCross = "\182" ; ╢
EndSwitch
; -------------------------------------------------------------------------------------
; At the designated coordinate, draw the specified line
; -------------------------------------------------------------------------------------
@ StartRow, StartColumn ?? LeftCross, Fill(HorizontalCross,Fillnum), RightCross
Endproc
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ EXAMPLE ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ To make a wide-lined white box on a cyan background, beginning at row ║
; ║ 3, column 11, and ending at row 21, column 64, with no intersecting ║
; ║ "cross lines": ║
; ║ Make_Box("Wide", 63, 03, 11, 21, 64, "", "") ║
; ║ ║
; ║ N. B. This box should be drawn on a black background. Accordingly, ║
; ║ if your canvas is not already black, precede the above with ║
; ║ the following command: ║
; ║ Paintcanvas Attribute 00 00, 00, 24, 79 Style attribute 15 ║
; ║ ║
; ╚══════════════════════════════════════════════════════════════════════════════════════╝